import request from '@/utils/request'

const api_name = '/admin/edu/course'

export default {
  // 保存课程信息
  saveCourseInfo(courseInfo) {
    return request({
      url: `${api_name}/save-course-info`,
      method: 'post',
      data: courseInfo
    })
  },

  // 根据id查询课程信息
  getCourseInfoById(id) {
    return request({
      url: `${api_name}/course-info/${id}`,
      method: 'get'
    })
  },

  // 根据id更新课程信息
  updateCourseInfoById(courseInfo) {
    return request({
      url: `${api_name}/update-course-info`,
      method: 'put',
      data: courseInfo
    })
  },

  // 获取课程列表
  getPageList(page, limit, searchObj) {
    return request({
      url: `${api_name}/list/${page}/${limit}`,
      method: 'get',
      params: searchObj
    })
  },

  // 根据id删除课程
  removeById(id) {
    return request({
      url: `${api_name}/remove/${id}`,
      method: 'delete'
    })
  },

  // 获取课程发布信息
  getCoursePublishById(id) {
    return request({
      url: `${api_name}/course-publish/${id}`,
      method: 'get'
    })
  },

  // 发布课程
  publishCourseById(id) {
    return request({
      url: `${api_name}/publish-course/${id}`,
      method: 'put'
    })
  }
}
